﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CuaHangLaptop.DAL;

namespace CuaHangLaptop.BIZ
{
    public class LaptopIMG_BIZ
    {
        LaptopIMG_DAL lapIMG_dal = new LaptopIMG_DAL();

        int id;
        string maIMG;
        Laptop_BIZ laptop = new Laptop_BIZ();
        string url;

        public int ID
        {
            get { return id; }
            set { id = value; }
        }

        public string MaIMG
        {
            get { return maIMG; }
            set { maIMG = value; }
        }

        public Laptop_BIZ Laptop
        {
            get { return laptop; }
            set { laptop = value; }
        }

        public string URL
        {
            get { return url; }
            set { url = value; }
        }

        public LaptopIMG_BIZ()
        {
        }

        public LaptopIMG_BIZ(int _id, string _maIMG, string _malap, string _url)
        {
            id = _id;
            maIMG = _maIMG;
            laptop = laptop.Get_Laptop_ByCode(_malap);
            url = _url;
        }

        public LaptopIMG_BIZ Get_IMG_ByCode(string _MaIMG)
        {
            return lapIMG_dal.Get_IMG_ByCode(_MaIMG);
        }

        public List<LaptopIMG_BIZ> GetAll_IMG()
        {
            return lapIMG_dal.GetAll_IMG();
        }

        public void Save()
        {
            if (id == -1) id = lapIMG_dal.Insert(this);
            else lapIMG_dal.Update(this);
        }

        public void Delete()
        {
            lapIMG_dal.Delete(this);
        }
    }
}
